<?php 
	include '../init.php';
	include ADMIN_PATH.'/header.php';

	$model=new Model('category');

	$sql="select `id`,`name`,`pid`,`path`,concat(path,id) bpath from `category` order by bpath";
	$list=$model->find($sql);
	foreach ($list as $key => $value) 
	{
		//第几级
		$num=count(explode(',', rtrim($value['path'],',')))-1;
		$list[$key]['name']=str_repeat('&nbsp;&nbsp;', $num).$value['name'];

		//var_dump($list);
	}
?>
<div class="m_right">
	<div class="m_main">
		<h1>添加商品</h1>
		<br/>
		<form action="<?php echo ADMIN_URL;?>/goods/action.php?a=add" method="post" enctype="multipart/form-data">
			商品名:
				<input type="text" name="name" placeholder="填写商品名"/>
				<br/>
			分 类 &nbsp;:
				<select name="cate_id">
					<?php foreach ($list as $k => $v) :?>
						<option value="<?php echo $v['id'];?>"><?php echo $v['name'];?></option>
					<?php endforeach;?>
				</select>
				<br/>
			价 格 &nbsp;:
				<input type="text" name="price" placeholder="填写价格"/>
				<br/>
			库 存 &nbsp;:
				<input type="text" name="stock" holderplace="填写库存量"/>
				<br/>
			图 片 &nbsp;:
				<input type="file" name="pic"/>
				<br/>
			描 述 &nbsp;:
				<textarea name="description"></textarea>
				<br/>
			<input type="submit" value="添加"/>
		</form>
	</div>
</div>
<?php 
	include ADMIN_PATH.'/footer.html';
?>